package com.sens.common;


import android.content.pm.ApplicationInfo;

import java.util.regex.Pattern;

import de.robv.android.xposed.callbacks.XC_LoadPackage;

public abstract class BaseHooker {
    private String packageName;

    public BaseHooker(String packageName) {
        this.packageName = packageName;
    }

    public final void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
        if (lpparam.appInfo == null || (lpparam.appInfo.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0)
            return;
        if (Pattern.matches(packageName, lpparam.packageName)) handlePackage(lpparam);
    }

    public abstract void handlePackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable;
}